// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/base/api/AlarmDashboardApi'

import QueryAlarmTotalReq from '@api/base/model/QueryAlarmTotalReq'
import QueryAlarmLevelTotalReq from '@api/base/model/QueryAlarmLevelTotalReq'
import QueryAlarmResolveStateTotalReq from '@api/base/model/QueryAlarmResolveStateTotalReq'
import QueryAlarmPerHourTotalReq from '@api/base/model/QueryAlarmPerHourTotalReq'
import QueryAlarmSubSystemTotalReq from '@api/base/model/QueryAlarmSubSystemTotalReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 告警总数 —————————————————————————————— //

  async getAlarmTotal(param = {}, TIP = `查询${CORE.MAP.ALARM}总数`) {
    const DTO = CORE.grpcDTO(QueryAlarmTotalReq, param)
    const { quantity } = await CORE.grpc(TIP, CLIENT, 'queryAlarmTotal', DTO)
    return [quantity]
  },
  // —————————————————————————————— 告警统计（等级） —————————————————————————————— //

  async getAlarmLevelTotal(param = {}, TIP = `查询${CORE.MAP.ALARM}统计（等级）`) {
    const DTO = CORE.grpcDTO(QueryAlarmLevelTotalReq, param)
    const { content } = await CORE.grpc(TIP, CLIENT, 'queryAlarmLevelTotal', DTO)
    return [content]
  },
  // —————————————————————————————— 告警统计（状态） —————————————————————————————— //

  async getAlarmResolveStateTotal(param = {}, TIP = `查询${CORE.MAP.ALARM}统计（状态）`) {
    const DTO = CORE.grpcDTO(QueryAlarmResolveStateTotalReq, param)
    const { content } = await CORE.grpc(TIP, CLIENT, 'queryAlarmResolveStateTotal', DTO)
    return [content]
  },
  // —————————————————————————————— 告警趋势 —————————————————————————————— //

  async getAlarmPerHourTotal(param = {}, TIP = `查询${CORE.MAP.ALARM}趋势`) {
    const DTO = CORE.grpcDTO(QueryAlarmPerHourTotalReq, param)
    const { content } = await CORE.grpc(TIP, CLIENT, 'queryAlarmPerHourTotal', DTO)
    return [content]
  },
  // —————————————————————————————— 告警分布 —————————————————————————————— //

  async getAlarmSubSystemTotal(param = {}, TIP = `查询${CORE.MAP.ALARM}分布`) {
    const DTO = CORE.grpcDTO(QueryAlarmSubSystemTotalReq, param)
    const { content } = await CORE.grpc(TIP, CLIENT, 'queryAlarmSubSystemTotal', DTO)
    return [content]
  },
}
